layui.config({
    version: '20180325',
    base: '../../assets/js/'
});
layui.define(['oneplatform', 'table', 'laydate'], function (exports) {

    var $ = layui.jquery
        , laypage = layui.laypage
        , table = layui.table
        , laydate = layui.laydate
    oneplatform = layui.oneplatform;

    laydate.render({
        elem: '#start'
        , min: '2017-1-1'
    });
    laydate.render({
        elem: '#end'
        , min: '2017-1-1'
    });


    var $table = table.render({
        elem: '#tablecont'
        , height: 450
        , width: 1200
        , url: '/api/wechat/replycontent/getlist'
        , method: 'POST'
        , page: true //开启分页
        , request: {
            pageName: 'pageNo'
            , limitName: 'pageSize'
        }
        , response: {
            statusName: 'code'
            , statusCode: 200
            , dataName: 'data'
        }
        , cols: [[ //表头
            { field: 'id', title: 'ID', width: 180, sort: true, fixed: 'left' }
            , { field: 'wid', title: '公众号id', width: 120, sort: true }
            , { field: 'wname', title: '公众号名称', width: 120, sort: true }
            , { field: 'keyWord', title: '匹配关键字', width: 150 }

            , { field: 'replyContent', title: '回复内容', width: 400 }
            , { field: 'createTime', title: '创建时间', width: 170 }

            , { fixed: 'right', width: 70, align: 'center', toolbar: '#toolBar' }
        ]]
    });

    //监听工具条
    table.on('tool(table)', function (obj) {
        var data = obj.data, layEvent = obj.event;
        oneplatform.iframeDialog('编辑', 'replycontent_edit.html?id=' + data.id);
    });

    $('.J_search').on('click', function () {
        $table.reload({
            where: oneplatform.serializeJson($('#searchform'))
            , page: {
                curr: 1
            }
        });
    });

    exports('log', null);

});